package main

import (
	"math/rand"
	"fmt"
	"sync"
	"time"
)

func testMap() {
	var a map[int]int
	a = make(map[int]int, 5)

	a[8] = 10
	a[3] = 10
	a[2] = 10
	a[1] = 10
	var m sync.Mutex
	for i := 0; i < 2; i++ {
		go func(b map[int]int) {
			m.Lock()
			b[1] = rand.Intn(100)
			m.Unlock()
		}(a)
	}
	m.Lock()
	fmt.Println(a)
	m.Unlock()
	time.Sleep(1 * time.Second)
}

func main() {
	testMap()
}
